package com.ybkj.o2o.zhuanxian.manager.impl;

import com.ybkj.o2o.zhuanxian.entity.OrderMemo;
import com.ybkj.o2o.zhuanxian.manager.OrderMemoManager;
import com.ybkj.o2o.zhuanxian.service.OrderMemoService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class DefaultOrderMemoManager implements OrderMemoManager {

  @Autowired
  private OrderMemoService orderMemoService;

  @Override
  public List<OrderMemo> findByOrderId(Long orderId) {

    return orderMemoService.findByOrderId(orderId);
  }

  @Override
  @Transactional(rollbackFor = Exception.class)
  public OrderMemo insert(OrderMemo orderMemo) {
    int rowCount = orderMemoService.insert(orderMemo);
    if (rowCount != 1) {
      throw new RuntimeException("创建订单备注失败");
    }
    return orderMemo;
  }
}
